package com.lggry.array.branch;

public class WhileDemo1 {
    public static void main(String[] args) {
        forWhile();
        getYear();
        getPaper();
    }

    public static void forWhile(){
        int i = 0;
        while (i<3){
            System.out.println("Hello World!");
            i++;
        }
    }

    //本金10万，复利是1.7%;请问多少年后翻倍
    public static void getYear(){
        double money = 100000;
        double rate = 1.7/100;
        int year = 0;
        while(money<=200000){
            money = money*(1+rate);
            year++;
        }
        System.out.println(year);
    }

    //珠穆朗玛峰高度：8848.86米 = 8848860mm,一张纸厚度0.1毫米，请问该纸叠多少次可以折成珠穆朗玛峰的高度
    public static void getPaper(){
       double mountainHeight = 8848860;
       double paperHeight = 0.1;
       int count = 0;
       while(paperHeight<mountainHeight){
           paperHeight = paperHeight * 2;
           count++;
       }
       System.out.println(count);
    }
}
